import request from '@/config/axios'

// ERP 发票 VO
export interface InvoiceVO {
  id: number // id
  invoiceNumber: string // 发票编号
  supplierId: number // 供应商编号
  invoiceValue: number // 发票金额，单位：元
  fileUrl: string // 附件 URL
}

// ERP 发票 API
export const InvoiceApi = {
  // 查询ERP 发票分页
  getInvoicePage: async (params: any) => {
    return await request.get({ url: `/erp/invoice/page`, params })
  },

  // 查询ERP 发票详情
  getInvoice: async (id: number) => {
    return await request.get({ url: `/erp/invoice/get?id=` + id })
  },

  // 新增ERP 发票
  createInvoice: async (data: InvoiceVO) => {
    return await request.post({ url: `/erp/invoice/create`, data })
  },

  // 修改ERP 发票
  updateInvoice: async (data: InvoiceVO) => {
    return await request.put({ url: `/erp/invoice/update`, data })
  },

  // 删除ERP 发票
  deleteInvoice: async (id: number) => {
    return await request.delete({ url: `/erp/invoice/delete?id=` + id })
  },

  // 导出ERP 发票 Excel
  exportInvoice: async (params) => {
    return await request.download({ url: `/erp/invoice/export-excel`, params })
  },
  // 根据审核单编号 查询发票列表
  getInvoiceListByCheckInvoiceId: async (checkInvoiceId) => {
    return await request.get({ url: `/erp/invoice/get-list-by-check-invoice-id?checkInvoiceId=` + checkInvoiceId })
  },
   // 根据编号 查询发票列表
   getInvoiceCheckListItemByNumbers: async (params: any) => {
    return await request.get({ url: `/erp/invoice-check-list-item/getInvoiceCheckListItemByNumbers` , params})
  },
  getNumAndPrice: async (params: any) => {
    return await request.get({ url: `/erp/invoice-check-list-item/getNumAndPrice` , params})
  },
    // 查询ERP 发票详情
  getInvoiceByOrderIntegrateId: async (params: any) => {
    return await request.get({ url: `/erp/invoice/getInvoiceByOrderIntegrateId` , params })
  },

  // 根据随货同行单的采购单编号数组 查询发票列表
  getInvoiceListByPurchaseOrderIds: async (purchaseOrderIds: any) => {
    // return await request.get({ url: `/erp/invoice/get-list-by-purchase-order-ids`,params: { purchaseOrderIds } })
    return await request.get({ url: `/erp/invoice/get-list-by-purchase-order-ids?purchaseOrderIds=` + purchaseOrderIds })
  },
  
}
